import request from '@/router/axios'
import moment from 'moment';
import {fenExYuangettoFixed} from "../../../subwayRat/commonCheck";
export function getXw_bom_shouJieSuan_waitSubmit(query) {
  let longSearch = query.longSearch;
  if(longSearch==1){
    query.endSettleDate = moment(query.endSettleDate).add(1,'days').format("YYYY-MM-DD")+" 01:59:59";
    //query.endTime = query.endSettleDate;
  }
  return request({
    url: '/check/xw_js_bom/getXw_bom_shouJieSuan_waitSubmit',
    method: 'post',
    params: query
  })
}

export function getXw_bom_shouJieSuan_reportError_waitSubmit(query) {
  return request({
    url: '/check/xw_js_bom/getXw_bom_shouJieSuan_reportError_waitSubmit',
    method: 'post',
    params: query
  })
}

export function bomSubmitTvmData(query) {
  return request({
    url: '/check/xw_js_bom/bomSubmitTvmData',
    method: 'post',
    // params: query
    data:query
  })
}

//查看是否有待确认数据
export function getBomNotConfirmDatas(query) {
  return request({
    url: '/check/xw_js_bom/getBomNotConfirmDatas',
    method: 'post',
    params: query,
    data:query
  })
}

//查看是否有待确认数据
export function getReportBomNotConfirmDatas(query) {
  return request({
    url: '/check/xw_js_bom/getReportBomNotConfirmDatas',
    method: 'post',
    params: query,
    data:query
  })
}

export function waitSubmitMainOptionList(){
  return {
    emptyBtn:false,
    editBtn:false,
    delBtn:false,
    addBtn:false,
    refreshBtn:false,
    columnBtn:false,
    border: true,
    index:true,
    indexLabel:'序号',
    page:false,
    align:'center',
    menuWidth:150,
    menuAlign:'center',
    selection: true,
    reserveSelection:false,
    height: 450,
    column:[
      {prop:"conductorName", label:"售票员",search:true},
      // {prop:"handlePersonCode", label:"员工号"},
      {prop:"conductorJobNo", label:"员工号"},
      {prop:"deviceOperateNum", label:"设备操作号"},
      {prop:"preJieSuanDate", label:"上次结算日期", hide: true, type:'date',valueFormat:'yyyy-MM-dd',formatter:function (row,v) {
          if(!v){
            return moment(row.settleTime).subtract(1,'days').format('YYYY-MM-DD');
          }else{
            return moment(row.endSettleDate).format('YYYY-MM-DD');
          }
        }},
      {prop:"settleTime", label:"收入日期",search:true,type:'date',valueFormat:'yyyy-MM-dd'},
      {prop:"dailyCashTotalAmount", hide:true, label:"最晚提交日期",formatter:function(row,v){
          if(row.settlementTerm>=0){
            return moment(row.check_submit_end_date).subtract(1,"days").format('YYYY-MM-DD');
          }else{
            return row.settleTime;
          }
        }},
      {prop:"realAmount", label:"现金实收金额",formatter:function (row,v) {
          if(v){
            return Number(v).toFixed(2);
          }
          return v;
        }},
      {prop:"electronicAmount", label:"团购电子金额",formatter:function (row,v) {
          if(v){
            return Number(v).toFixed(2);
          }
          return v;
        }},

    ]
  }
}




export function reportWaitSubmitMainOptionList(){
  return {
    emptyBtn:false,
    editBtn:false,
    delBtn:false,
    addBtn:false,
    refreshBtn:false,
    columnBtn:false,
    border: true,
    index:true,
    indexLabel:'序号',
    page:false,
    align:'center',
    menuWidth:150,
    menuAlign:'center',
    selection: true,
    reserveSelection:false,
    height: 450,
    column:[
      {prop:"conductorName", label:"售票员",search:true},
      // {prop:"handlePersonCode", label:"员工号"},
      {prop:"conductorJobNo", label:"员工号"},
      {prop:"deviceOperateNum", label:"设备操作号"},
      {prop:"preJieSuanDate", label:"上次结算日期", hide:true, type:'date',valueFormat:'yyyy-MM-dd',formatter:function (row,v) {
          if(!v){
            return moment(row.settleTime).subtract(1,'days').format('YYYY-MM-DD');
          }else{
            return moment(row.endSettleDate).format('YYYY-MM-DD');
          }
        }},
      {prop:"settleTime", label:"收入日期",type:'date',valueFormat:'yyyy-MM-dd',search:true,searchslot:true},
      {prop:"dailyCashTotalAmount", label:"最晚提交日期",formatter:function(row,v){
          if(row.settlementTerm>=0){
            return moment(row.settleTime).add(row.settlementTerm, 'days').format('YYYY-MM-DD');
          }else{
            return row.settleTime;
          }
        }},
      {prop:"realAmount", label:"现金实收金额",formatter:function (row,v) {
          if(v){
            return Number(v).toFixed(2);
          }
          return v;
        }},
      {prop:"electronicAmount", label:"团购电子金额",formatter:function (row,v) {
          if(v){
            return Number(v).toFixed(2);
          }
          return v;
        }},

    ]
  }
}

export function getPreview(row){
  let res={};
  res.lineCode=row.lineCode;
  res.stationCode=row.stationCode;
  res.conductorName=row.conductorName;
  res.settleTime=row.settleTime;
  res.recordTime=row.settleTime;
  res.deviceOperatorNum=row.deviceOperateNum;
  res.settleEndTime='';
  res.conductorShifts=row.conductorShifts;
  res.cashReceiptAmount=row.realAmount;
  res.electronicAmount=row.electronicAmount;
  res.passengerAttendantJobNo='';
  res.attendancePersonJobNo='';
  res.conductorJobNo=row.conductorJobNo;
  res.settleStartTime='';
  res.advanceAmount=row.adanceAmount;
  res.passengerAttendantName='';
  res.attendancePersonName='';
  res.yuFashouTicketNum='';
  res.yuFashouTicketAmount='';
  return res;
}
